package CollectionsDemo;

import java.util.ArrayList;
import java.util.Collections;
import java.io.*;
class Employee
	{
	int id;
	String name;
	String address;
	
	/*
	Employee()
		{
		System.out.println("In constructor");
		}
	
	
	void getEmployee()
		{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader bfr = new BufferedReader(isr);
		try
			{
			System.out.println("Enter the employee Name : ");
			this.name = bfr.readLine();
			System.out.println("Enter the employee Address : ");
			this.name = bfr.readLine();
			System.out.println("Enter the employee ID : ");
			this.id = bfr.read();
			}
		catch(IOException ioe)
			{
			System.out.println("Couldnot take input from keyboard");
			}
		InputStreamReader varname = new InputStreamReader(System.in);
		}
	*/
	public static void sortName(Employee e[])
		{
		ArrayList<String> ename = new ArrayList<String>();
		for(int i = 0; i<e.length; i++)
			{
			 ename.add(e[i].name);
		 	}
		Collections.sort(ename);
		for(int i=0; i<e.length; i++)
			{
			for(int j=0; j<e.length;j++)
			if(ename.get(i) == e[j].name)
				{
				e[j].showEmployee();
				}
			}
		}
	void showEmployee()
		{
		System.out.println("ID :" + this.id + "Name : " + this.name + " Address : " + this.address);
		}
	}

public class CollectionFrameworkDemo 
	{

	public static void main(String[] args) 
	{
	Employee e[] = new Employee[3];
	for(int i=0;i<e.length;i++)
		e[i] = new Employee();
	e[0].id = 1;
	e[0].name = "Nitin";
	e[0].address = "Bangalore";
	
	e[1].id = 2;
	e[1].name = "Abhi";
	e[1].address = "Bangalore";
	
	e[2].id = 3;
	e[2].name = "Bala";
	e[2].address = "Bangalore";
	
	/*for(int i=0;i<e.length;i++)
		e[i].getEmployee();
	*/
	Employee.sortName(e);
	}

}
